var testObj = {
	init() {
		window.log = window.console.log;
		window.alert = function(msg) {
			log(msg);
		}
		this.time = 0;
		this.test();
	},
	async test() {
		
		var input = document.querySelector('input');
		var submit = input.nextElementSibling;
		log('1. 测试提交空内容....');
		input.value = '';
		submit.click();
		log('2. 测试添加内容...');
		await this.delay(1);
		input.value = '篮球';
		submit.click();
		log('3. 测试数据提交后是否清空');
		if (input.value) {
			log('数据提交后没清空');
		} else {
			log('数据提交后已清空');
		}
		await this.delay(1);
		input.value = '足球';
		submit.click();
		await this.delay(1);
		input.value = '羽毛球';
		submit.click();
		log('选项添加完毕')
		log('4. 测试移动到左边...')
		var buttons = document.querySelectorAll('button.margin-left-30');
		for(var i = 0; i < buttons.length; i++) {
			await this.delay(1);
			buttons[i].click();
			log(`移动第${i+1}条数据`);
		}
		// log(`所有左边的数据已经移动到了右边.`);
		log('5. 测试移动到右边...')
		var buttons2 = document.querySelectorAll('#list2 .item button');
		for(var i = 0; i < buttons2.length; i++) {
			await this.delay(1);
			buttons2[i].click();
//			log(`移动第${i+1}条数据到右边`);
		}
		// log(`所有右边的数据已经移动到了左边.`);
	},
	delay(num, callback) {
		this.time = +num * 200;
		return new Promise((resolve, reject) => {
			setTimeout(function() {
				resolve(callback);
			}, this.time);
		})
	}
}
testObj.init();

function aaa() {
	var script = document.createElement('script');
	script.src = 'test.js'
	document.body.appendChild(script);
}